Skip to content

fix: retry truncated provider streams - #39473

Draft
Davide95 wants to merge 1 commit into
anomalyco:devfrom
Davide95:stream-truncation
Draft

fix: retry truncated provider streams#39473
Davide95 wants to merge 1 commit into
anomalyco:devfrom
Davide95:stream-truncation

Conversation

@Davide95

@Davide95 Davide95 commented Jul 29, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #37852

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

AI SDK synthesizes an other finish when a provider stream ends without a finish reason. OpenCode treated that as a completed unknown response, so a subagent could return an empty successful task result. This change converts that synthetic finish into a retryable stream error. It also propagates child assistant errors through the task tool, so retry exhaustion cannot become an empty success.

How did you verify your code works?

  • Added tests to cover it
  • Tested locally, and the issue seems gone
  • I'll distribute it to some people that are having this issue, and I'll report if it will fix it for all of them here

Screenshots / recordings

Not applicable: runtime-only change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:issue labels Jul 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

Related PR:

The current PR (39473) is specifically about handling AI SDK fallback finishes without provider finish reasons as retryable failures. The search results also show #26167 which dealt with stream truncations, but that appears to be older legacy work.

I did not find any exact duplicate PRs that are addressing the same issue (#37852) that your PR targets.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@Davide95
Davide95 force-pushed the stream-truncation branch from e41f17c to 27e6cd0 Compare July 29, 2026 09:31
@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

Skipping Bugbot: Bugbot could not find a matching SCM installation for this repository. Please reinstall the GitHub/GitLab installation and/or remove the installation from non-Bugbot accounts. Visit the Bugbot dashboard to update your settings.

@Davide95 Davide95 changed the title fix(opencode): retry truncated provider streams fix: retry truncated provider streams Jul 29, 2026
@Davide95

Copy link
Copy Markdown
Author

Quick update: a colleague of mine played with this patched version for a while, and he confirmed that the issue is resolved for him.
He sees a lot of errors from OpenAI sol, but at least retries work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aborted provider stream recorded as clean stop (finish=unknown, zero usage, no text) — subagent returns empty with no error

1 participant